package com.bleet.securitysms;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Input extends Activity implements OnClickListener{
	private EditText mPwd;
	private Button mNext, mUpdatePwd, mExit;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.step1);
        setupViews();
    }

	private void setupViews() {
		mPwd = (EditText) findViewById(R.id.password);
		mNext = (Button) findViewById(R.id.next1);
		mUpdatePwd= (Button) findViewById(R.id.changepwd);
		mExit = (Button) findViewById(R.id.exit);
		mNext.setOnClickListener(this);
		mUpdatePwd.setOnClickListener(this);
		mExit.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		if(v == mNext){
			String firstPwd = mPwd.getText().toString();
			if(SettingStatus.getPassword(this).equals(Security.toMd5(firstPwd.getBytes()))){
				Intent intent = new Intent(this, SecuritySMS.class);
				startActivity(intent);
			}else {
				Toast.makeText(this, getResources().getString(R.string.wrongpassword), Toast.LENGTH_LONG).show();
			}
		}else if (v == mUpdatePwd) {
			Intent intent = new Intent(this, ChangePwd.class);
			startActivity(intent);
		}else if (v == mExit) {
			finish();
		}
		
	}
}
